<style>
    label.red-start:before {
        content: '* ';
        color: red;
    }
    .layui-form-label{
        width:100px;
    }
</style>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <form id="addFrm" class="layui-form" action="" lay-filter="component-form-group">
                <input type="hidden" name="id" value="<?= !empty($editData["id"]) ? $editData["id"] : 0 ?>">
                <input type="hidden" name="order_id" value="<?= $order_id ?>">
                <input type="hidden" name="type_id" value="<?= $type_id ?>">
                <div class="layui-form-item">
                    <label class="layui-form-label red-start">费用类型</label>
                    <div class="layui-input-inline">
                        <select name="fee_type" lay-filter="fee_type">
                            <option value="0"></option>
                            <?php foreach ($feeType as $k => $v) { ?>
                                <option value="<?= $k ?>"<?= !empty($editData["fee_type"]) && $editData["fee_type"] == $k ? " selected" : "" ?>><?= $v["name"] ?></option>
                            <?php } ?>
                        </select>
                    </div>
                    <label class="layui-form-label red-start">计费方式</label>
                    <div class="layui-input-inline">
                        <select name="unit" lay-filter="unit">
                            <option value="0"></option>
                            <?php foreach ($unit as $k => $v) { ?>
                                <option value="<?= $k ?>"<?= !empty($editData["unit"]) && $editData["unit"] == $k ? " selected" : "" ?>><?= $v["name"] ?></option>
                            <?php } ?>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">单价</label>
                    <div class="layui-input-inline">
                        <input type="text" name="unit_fee" id="unit_fee" onkeyup="return tongji()" value="<?= !empty($editData['unit_fee']) ? $editData['unit_fee'] : ""; ?>" autocomplete="off" placeholder="" class="layui-input">
                    </div>
                    <label class="layui-form-label">数量</label>
                    <div class="layui-input-inline">
                        <input type="text" name="num" id="num" onkeyup="return tongji()" value="<?= !empty($editData['num']) ? $editData['num'] : 1; ?>" autocomplete="off" placeholder="" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label red-start">总费用</label>
                    <div class="layui-input-inline">
                        <input type="text" name="total_fee" id="total_fee" value="<?= !empty($editData['total_fee']) ? abs($editData['total_fee']) : ""; ?>" autocomplete="off" placeholder="" class="layui-input">
                    </div>
                    <?php
                    if ($type_id == 2) {
                        ?>
                        <label class="layui-form-label red-start">供应商</label>
                        <div class="layui-input-inline">
                            <select name="custom_id">
                                <option value="0"></option>
                                <?php foreach ($custom as $k => $v) { ?>
                                    <option value="<?= $v["id"] ?>"<?= !empty($editData["custom_id"]) && $editData["custom_id"] == $v["id"] ? " selected" : "" ?>><?= $v["cmp_bf"] ?></option>
                                <?php } ?>
                            </select>
                        </div>
                    <?php } ?>
                </div>
                <div class="layui-form-item" id="mileage_info" style="display: <?= !empty($editData['fee_type']) && $editData['fee_type'] == 2 ? "" : "none"; ?>">
                    <label class="layui-form-label">开始公里数</label>
                    <div class="layui-input-inline">
                        <input type="text" name="start_mileage" id="start_mileage" value="<?= !empty($editData['start_mileage']) ? $editData['start_mileage'] : ""; ?>" autocomplete="off" placeholder="" class="layui-input">
                    </div>
                    <label class="layui-form-label">结束公里数</label>
                    <div class="layui-input-inline">
                        <input type="text" name="end_mileage" id="end_mileage" value="<?= !empty($editData['end_mileage']) ? $editData['end_mileage'] : ""; ?>" autocomplete="off" placeholder="" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">备注</label>
                    <div class="layui-input-inline">
                        <input type="text" name="remark" value="<?= !empty($editData['remark']) ? $editData['remark'] : ""; ?>" autocomplete="off" placeholder="" class="layui-input">
                    </div>
                    <div id="transport_type_dom" style="display:<?= !empty($editData['fee_type']) && $editData['fee_type'] == 2 ? "" : "none"; ?>">
                        <label class="layui-form-label red-start">运输类型</label>
                        <div class="layui-input-inline">
                            <select name="transport_type" lay-filter="transport_type">
                                <option value="0"></option>
                                <?php foreach ($transportType as $k => $v) { ?>
                                    <option value="<?= $k ?>"<?= !empty($editData["transport_type"]) && $editData["transport_type"] == $k ? " selected" : "" ?>><?= $v["name"] ?></option>
                                <?php } ?>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button type="button" class="layui-btn customize" lay-filter="formDemo" id="submitBtn">确定提交</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script>
    var doAddUrl = "<?= $doAddUrl ?>";
    var getPreMileageUrl = "<?= $this->projectSet["url"]["getPreMileage"] ?>";
    var getOrderWeightUrl = "<?= $this->projectSet["url"]["getOrderWeight"] ?>";
    var order_id = "<?= $order_id ?>";
    var id = "<?= !empty($editData["id"]) ? $editData["id"] : 0 ?>";
</script>
<script>
    layui.use(['laypage', 'layer', 'form', 'element', 'laydate'], function () {
        var laypage = layui.laypage,
                frm = layui.form,
                layer = layui.layer,
                element = layui.element,
                laydate = layui.laydate;

        laydate.render({
            elem: '#fee_date' //指定元素
                    //type: "datetime"
                    //range: true
        });

        frm.on('select(fee_type)', function (data) {
            changeFeeType(data.value);
        });

        frm.on('select(unit)', function (data) {
            changeUnit(data.value);
        });

    });
</script>
<script src="<?= PUBLIC_URL . "/" . $this->projectSet["file"]["js"] . "/add.js?" . rand() ?>"></script>
